home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 015 / ansiprt.arc / ANSIPRT.C next >
Encoding:
Text File  |  1985-09-28  |  1.5 KB  |  54 lines

  1. #include "stdio.h"
  2.  
  3. FILE            *f1,*f2,*fopen();
  4. static unsigned char linein[256];
  5. static unsigned char   *ap,*cp;
  6. static int x;
  7.  
  8. main(argc,argv)
  9. unsigned int argc;
  10. unsigned char **argv;
  11. {
  12.     if (argc != 2){
  13.         printf("\nABORT- Usage: programname infilename\n");
  14.         exit(1);
  15.     }
  16.     if ((f1 = fopen(argv[1], "r")) == NULL){
  17.           printf("\nABORT- Unable to open file: %s\n", argv[1]);
  18.           exit(1);
  19.       }
  20.     ap = "PRN:";
  21.     if ((f2 = fopen(ap, "w")) == NULL){
  22.           printf("\nABORT- Unable to access printer");
  23.           exit(1);
  24.       }
  25.     for (;;){
  26.         if ((fgets(linein,255,f1)) == 0) break;
  27.         if (linein[0] == '1'){
  28.                 fputc(0x0c,f2);
  29.                 goto detail;
  30.         }
  31.         if (linein[0] == '0'){
  32.                 fputc(0x0a,f2);
  33.                 fputc(0x0a,f2);
  34.                 goto detail;
  35.         }
  36.         if (linein[0] == '-'){
  37.                 fputc(0x0a,f2);
  38.                 fputc(0x0a,f2);
  39.                 fputc(0x0a,f2);
  40.                 goto detail;
  41.         }
  42.         if (linein[0] == '+') goto detail;
  43.         fputc(0x0a,f2);
  44. detail:
  45.         x = strlen(linein);
  46.         cp = &linein[1];
  47.         while (x-- > 2) fputc(*cp++,f2);
  48.         fputc(0x0d,f2);
  49.     }
  50.     fputc(0x0c,f2);
  51.     fclose(f1);
  52.     fclose(f2);
  53. }
  54.